using System;
using System.Collections.Generic;
using System.Text;
using HeThongDAO;
using DTO;
using System.Data;

namespace HeThongBUS
{
    public enum TaiKhoanBUSResult
    {
        OK,
        USERNAMEERROR,
        PASSWORDERROR,
        DAOERROR
    }

    public class TaiKhoanBUS
    {
        public static TaiKhoanBUSResult KiemTraDangNhap(TaiKhoanDTO tkDTO)
        {
            // Kiem tra du lieu nhap
            if (tkDTO.Username == "")
                return TaiKhoanBUSResult.USERNAMEERROR;
            if (tkDTO.Password == "")
                return TaiKhoanBUSResult.PASSWORDERROR;

            // Kiem tra dang nhap
            if (!TaiKhoanDAO.KiemTraDangNhap(tkDTO))
                return TaiKhoanBUSResult.DAOERROR;
            return TaiKhoanBUSResult.OK;
        }

        public static DataTable LayDanhSachTaiKhoan()
        {
            return TaiKhoanDAO.LayDanhSachTaiKhoan();
        }

        public static TaiKhoanBUSResult ThemTaiKhoan(TaiKhoanDTO tkDTO)
        {
            // Kiem tra du lieu nhap


            if (!TaiKhoanDAO.ThemTaiKhoan(tkDTO))
                return TaiKhoanBUSResult.DAOERROR;
            return TaiKhoanBUSResult.OK;
        }

        public static TaiKhoanBUSResult CapNhatTaiKhoan(TaiKhoanDTO tkDTO)
        {
            // Kiem tra du lieu nhap


            if (!TaiKhoanDAO.CapNhatTaiKhoan(tkDTO))
                return TaiKhoanBUSResult.DAOERROR;
            return TaiKhoanBUSResult.OK;
        }

        public static TaiKhoanBUSResult XoaTaiKhoan(TaiKhoanDTO tkDTO)
        {
            // Kiem tra du lieu nhap


            if (!TaiKhoanDAO.XoaTaiKhoan(tkDTO))
                return TaiKhoanBUSResult.DAOERROR;
            return TaiKhoanBUSResult.OK;
        }
    }
}
